package com.suse.ecommerce.serviceImp;

import com.suse.ecommerce.dao.StoreMapper;
import com.suse.ecommerce.pojo.Store;
import com.suse.ecommerce.pojo.StoreExample;
import com.suse.ecommerce.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    private StoreMapper storeMapper;
    @Override
    public Store checkAdminLogin(String nick, String password) {
        StoreExample storeExample=new StoreExample();
        StoreExample.Criteria criteria = storeExample.createCriteria();
        criteria.andPasswordEqualTo(password);
        criteria.andStoreNickEqualTo(nick);
        List<Store> stores = storeMapper.selectByExample(storeExample);
        if(stores.size()==0){
            return null;
        }
        return stores.get(0);
    }
}
